<?php

include_once("DataProvider.php");
//sleep( 3 );

require "JSON.php";

$url		= $_POST['url'];
$form_type	= $_POST['form_type'];
$id			= $_POST['id'];
$orig_value	= $_POST['orig_value'];
$new_value	= $_POST['new_value'];


if(isset($_GET['col']) && $_GET['col']==1)
{
	$sql="update sanpham set tensanpham='".$_POST['new_value']."' where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}
else if(isset($_GET['col']) && $_GET['col']==3)
{
	$sql="update sanpham set gia=".$_POST['new_value']." where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}
else if(isset($_GET['col']) && $_GET['col']==4)
{
	$sql="update sanpham set motasanpham='".$_POST['new_value']."' where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}
else if(isset($_GET['col']) && $_GET['col']==5)
{
	$sql="update sanpham set motachitiet='".$_POST['new_value']."' where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}
else if(isset($_GET['col']) && $_GET['col']==6)
{
	$sql="update sanpham set motasanpham='".$_POST['new_value']."' where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}
else if(isset($_GET['col']) && $_GET['col']==7)
{
	$sql="update sanpham set ngaycapnhat='".$_POST['new_value']."' where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}
else if(isset($_GET['col']) && $_GET['col']==8)
{
	$sql="update sanpham set tinhtrang=".$_POST['new_value']." where id_sanpham=".$_GET['id_'];
	DataProvider::ExecuteQuery($sql);
}

if( $form_type == 'select' ) {
	$orig_option_text	= $_POST['orig_option_text'];
	$new_option_text	= $_POST['new_option_text'];

	$new_value			= $new_option_text;
}

$json = new Services_JSON( );

print $json->encode( array(
	"is_error"		=> false,
	"error_text"	=> "Ack!  Something broke!",
	"html"			=> $new_value
) );

?>